package com.zhx.real.security;


import com.zhx.real.security.logout.ZhxLogoutSuccessHandler;
import com.zhx.real.security.session.ZhxExpiredSessionStrategy;
import com.zhx.real.security.session.ZhxInvalidSessionStrategy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.security.web.session.InvalidSessionStrategy;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

/**
 * @author zhanghaixuan
 * @create 2017/11/26-下午10:14
 **/
@Configuration
public class BrowserSecurityBeanConfig {
	@Bean
	@ConditionalOnMissingBean(InvalidSessionStrategy.class)
	public InvalidSessionStrategy invalidSessionStrategy() {
		return new ZhxInvalidSessionStrategy();
	}

	@Bean
	@ConditionalOnMissingBean(SessionInformationExpiredStrategy.class)
	public SessionInformationExpiredStrategy sessionInformationExpiredStrategy() {
		return new ZhxExpiredSessionStrategy();
	}

	@Bean
	@ConditionalOnMissingBean(LogoutSuccessHandler.class)
	public LogoutSuccessHandler logoutSuccessHandler() {
		return new ZhxLogoutSuccessHandler();
	}
}